home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / text / hyper / hsc_source.lha / hsc / source / ugly / prginfo.c < prev    next >
C/C++ Source or Header  |  1996-11-04  |  4KB  |  157 lines

  1. /*
  2.  * ugly/prginfo.c
  3.  *
  4.  * ugly program info functions
  5.  *
  6.  * Copyright (C) 1994,95,96  Thomas Aglassinger
  7.  *
  8.  * This program is free software; you can redistribute it and/or modify
  9.  * it under the terms of the GNU General Public License as published by
  10.  * the Free Software Foundation; either version 2 of the License, or
  11.  * (at your option) any later version.
  12.  *
  13.  * This program is distributed in the hope that it will be useful,
  14.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.  * GNU General Public License for more details.
  17.  *
  18.  * You should have received a copy of the GNU General Public License
  19.  * along with this program; if not, write to the Free Software
  20.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  *
  22.  * updated: 27-Oct-1996
  23.  * created:  3-Jul-1994
  24.  *
  25.  *=========================================================
  26.  * TODO:
  27.  * - set_prginfo()-macro: replace "name" by "( name ? name : argv[0] )"
  28.  *
  29.  */
  30.  
  31. /* ANSI includes */
  32. #include <stdlib.h>
  33. #include <stdio.h>
  34. #include <string.h>
  35.  
  36. #include "utypes.h"
  37.  
  38. #define SIZE_DATESTR 24
  39.  
  40. #ifdef AMIGA
  41. /* system version string on amiga systems */
  42. STRPTR amiga_version = "";
  43. #endif
  44.  
  45. /*
  46.  * local global vars
  47.  */
  48. STRPTR pi_progname = NULL;      /* exported */
  49. STRPTR pi_authname = NULL;
  50. int pi_version = 0;
  51. int pi_release = 0;
  52. int pi_revision = 0;
  53. char pi_rel_date[SIZE_DATESTR];
  54. STRPTR pi_rel_time = NULL;
  55. STRPTR pi_descript = NULL;
  56. STRPTR pi_copystat = NULL;
  57.  
  58. STRPTR pi_dt_day = NULL;
  59. STRPTR pi_dt_month = NULL;
  60. STRPTR pi_dt_year = NULL;
  61.  
  62. /*
  63.  * call_set_prginfo
  64.  *
  65.  * set pi_xxx vars; called by macro set_info()
  66.  *
  67.  */
  68. void call_set_prginfo(STRPTR name, STRPTR auth, int ver, int rel, int rev,
  69.         STRPTR rel_date, STRPTR rel_time, STRPTR infostr, STRPTR copystatus)
  70. {
  71.     pi_progname = name;
  72.     pi_authname = auth;
  73.     pi_version = ver;
  74.     pi_release = rel;
  75.     pi_revision = rev;
  76.     pi_rel_time = rel_time;
  77.     pi_descript = infostr;
  78.     pi_copystat = copystatus;
  79.  
  80.     strncpy(pi_rel_date, rel_date, SIZE_DATESTR);
  81.     pi_rel_date[3] = '\0';
  82.     pi_rel_date[6] = '\0';
  83.     pi_dt_month = pi_rel_date;
  84.     pi_dt_day = &(pi_rel_date[4]);
  85.     if (pi_dt_day[0] == ' ')
  86.         pi_dt_day++;
  87.     pi_dt_year = &(pi_rel_date[7]);
  88. }
  89.  
  90. /*
  91.  * call_set_prginfo2
  92.  *
  93.  * set pi_xxx vars; called by macro set_info()
  94.  *
  95.  * NOTE: this version expects date "DD.MM.YY"
  96.  */
  97. void call_set_prginfo2(STRPTR name, STRPTR auth, int ver, int rel, int rev,
  98.         STRPTR rel_date, STRPTR rel_time, STRPTR infostr, STRPTR copystatus)
  99. {
  100.     STRPTR monthName[] =
  101.     {"XXX", "Jan", "Feb", "Mar", "Apr", "May", "Jun",
  102.     "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
  103.  
  104.     pi_progname = name;
  105.     pi_authname = auth;
  106.     pi_version = ver;
  107.     pi_release = rel;
  108.     pi_revision = rev;
  109.     pi_rel_time = rel_time;
  110.     pi_descript = infostr;
  111.     pi_copystat = copystatus;
  112.  
  113.     strncpy(pi_rel_date, rel_date, SIZE_DATESTR);
  114.  
  115.     /* eval day */
  116.     pi_dt_day = pi_rel_date;
  117.  
  118.     /* eval month */
  119.     pi_dt_month = strchr(pi_rel_date, '.');
  120.     pi_dt_month[0] = '\0';
  121.     pi_dt_month++;
  122.  
  123.     /* eval year */
  124.     pi_dt_year = strchr(pi_dt_month, '.');
  125.     pi_dt_year[0] = '\0';
  126.     pi_dt_year++;
  127.  
  128.     /* convert numeric month */
  129.     pi_dt_month = monthName[strtol(pi_dt_month, NULL, 10)];
  130. }
  131.  
  132. /*
  133.  * fprintf_prginfo
  134.  *
  135.  * display program information
  136.  *
  137.  */
  138. int fprintf_prginfo(FILE * stream)
  139. {
  140.     int err = 0;
  141.  
  142.     err = fprintf(stream, "%s - %s, v%d.%d",
  143.                   pi_progname, pi_descript,     /* name & description */
  144.                   pi_version, pi_release);      /* version */
  145.     if (pi_revision)
  146.         err += fprintf(stream, ".%d",   /* revision */
  147.                        pi_revision);
  148.     err += fprintf(stream, " (%s-%s-%s)\n",     /* date */
  149.                    pi_dt_day, pi_dt_month, pi_dt_year);
  150.     err += fprintf(stream, "(C) %s. %s\n",      /* copyright */
  151.                    pi_authname, pi_copystat);
  152.  
  153.     return (err);
  154.  
  155. }
  156.  
  157.